#!/usr/bin/ruby
# -*- ruby -*-
#
# http://codeforces.com/problemset/problem/400/A

require 'pp'

def fill_table(a, b, line)
  table = Array.new(a)
  
  a.times do |i|
    table[i] = Array.new(b, nil)
  end

  line_idx = 0

  (0).upto(a - 1) do |i|
    (0).upto(b - 1) do |j|
      table[i][j] = line[line_idx]

      line_idx += 1
    end
  end

  return table
end

def solution?(a, b, line)
  table = fill_table(a, b, line)

  all_x = true
  
  (0).upto(b - 1) do |j|
    (0).upto(a - 1) do |i|
      all_x = false if table[i][j] != 'X'
    end

    return true if all_x

    all_x = true
  end

  return false
end

def process(line)
  solutions = []

  (1).upto(12).each do |a|
    next unless line.length % a == 0

    b = line.length / a

    solutions << [a, b] if solution?(a, b, line)
  end

  return solutions
end

n = nil

ARGF.each_with_index do |line, index|
  next if line.strip.empty?

  if n.nil?
    n = line.to_i
  else
    solutions = process(line.strip.split(//))

    puts solutions.size.to_s + " " + solutions.map { |(a, b)| "#{a}x#{b}" }.join(" ")
  end
end
